package view.client;

import control.client.BlockUserAction;
import control.client.DeletePostAction;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JLabel;
import util.EPanelTypes;

/**
 *
 * @author S3224743
 */
public class PostPanel extends javax.swing.JPanel
{
    //private fields
    private int topicID;
    private int postID;

    //private fields
    private BlockUserAction blockUserAction;
    private DeletePostAction deletePostAction;

    //public constructor
    public PostPanel()
    {
        initComponents();

        //initialized
        this.topicID=0;
        this.blockUserAction=new BlockUserAction(this);
        this.deletePostAction=new DeletePostAction(this);
        
        //actionListener
        this.blockBtn.addActionListener(blockUserAction);
        this.deletePostBtn.addActionListener(deletePostAction);
    }

    //properties
    public int getTopicID()
    {
        return this.topicID;
    }
    public void setTopicID(int topicID)
    {
        this.topicID=topicID;
    }

    public JButton getBlockBtn()
    {
        return blockBtn;
    }

    public JLabel getDateLbl()
    {
        return dateLbl;
    }

    public JLabel getMessageLbl()
    {
        return messageLbl;
    }

    public JButton getDeletePostBtn()
    {
        return deletePostBtn;
    }

    public JLabel getUsername()
    {
        return username;
    }

    public int getPostID()
    {
        return postID;
    }

    public void setPostID(int postID)
    {
        this.postID = postID;
    }

    //public methods
    public void showAdminPanel(EPanelTypes ePanelTypes)
    {
        switch(ePanelTypes)
        {
            case ADMIN:
                this.deletePostPanel.setPreferredSize(new Dimension(0,60));
                this.deletePostPanel.setSize(new Dimension(0,60));
                this.blockPanel.setPreferredSize(new Dimension(0,60));
                this.blockPanel.setSize(new Dimension(0,60));
                break;
            default:
                this.deletePostPanel.setPreferredSize(new Dimension(0,0));
                this.deletePostPanel.setSize(new Dimension(0,0));
                this.blockPanel.setPreferredSize(new Dimension(0,0));
                this.blockPanel.setSize(new Dimension(0,0));
                break;
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        username = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        dateLbl = new javax.swing.JLabel();
        blockPanel = new javax.swing.JPanel();
        blockBtn = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        messageLbl = new javax.swing.JLabel();
        deletePostPanel = new javax.swing.JPanel();
        deletePostBtn = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout(5, 20));

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel1.setMaximumSize(new java.awt.Dimension(175, 32767));
        jPanel1.setMinimumSize(new java.awt.Dimension(175, 100));
        jPanel1.setPreferredSize(new java.awt.Dimension(175, 207));
        jPanel1.setLayout(new java.awt.BorderLayout());

        username.setFont(new java.awt.Font("Tahoma", 0, 18));
        username.setText("username");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel4.setText("Posted at:");

        dateLbl.setFont(new java.awt.Font("Tahoma", 0, 14));
        dateLbl.setText("21/2/2011");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(username, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dateLbl, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(username)
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(dateLbl))
                .addContainerGap(170, Short.MAX_VALUE))
        );

        jPanel1.add(jPanel5, java.awt.BorderLayout.CENTER);

        blockPanel.setPreferredSize(new java.awt.Dimension(173, 60));

        blockBtn.setText("Block");

        javax.swing.GroupLayout blockPanelLayout = new javax.swing.GroupLayout(blockPanel);
        blockPanel.setLayout(blockPanelLayout);
        blockPanelLayout.setHorizontalGroup(
            blockPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, blockPanelLayout.createSequentialGroup()
                .addContainerGap(84, Short.MAX_VALUE)
                .addComponent(blockBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        blockPanelLayout.setVerticalGroup(
            blockPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(blockPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(blockBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(12, Short.MAX_VALUE))
        );

        jPanel1.add(blockPanel, java.awt.BorderLayout.PAGE_END);

        add(jPanel1, java.awt.BorderLayout.LINE_START);

        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jPanel3.setLayout(new java.awt.BorderLayout());

        messageLbl.setFont(new java.awt.Font("Tahoma", 0, 14));
        messageLbl.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        messageLbl.setText("Content message");
        messageLbl.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jPanel3.add(messageLbl, java.awt.BorderLayout.CENTER);

        deletePostPanel.setPreferredSize(new java.awt.Dimension(422, 60));

        deletePostBtn.setText("Delete Post");

        javax.swing.GroupLayout deletePostPanelLayout = new javax.swing.GroupLayout(deletePostPanel);
        deletePostPanel.setLayout(deletePostPanelLayout);
        deletePostPanelLayout.setHorizontalGroup(
            deletePostPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, deletePostPanelLayout.createSequentialGroup()
                .addContainerGap(325, Short.MAX_VALUE)
                .addComponent(deletePostBtn)
                .addContainerGap())
        );
        deletePostPanelLayout.setVerticalGroup(
            deletePostPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(deletePostPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(deletePostBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel3.add(deletePostPanel, java.awt.BorderLayout.PAGE_END);

        add(jPanel3, java.awt.BorderLayout.CENTER);
        this.jPanel3.add(Box.createHorizontalStrut(10),BorderLayout.WEST);
        this.jPanel3.add(Box.createHorizontalStrut(10),BorderLayout.EAST);
        this.jPanel3.add(Box.createVerticalStrut(10),BorderLayout.NORTH);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton blockBtn;
    private javax.swing.JPanel blockPanel;
    private javax.swing.JLabel dateLbl;
    private javax.swing.JButton deletePostBtn;
    private javax.swing.JPanel deletePostPanel;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JLabel messageLbl;
    private javax.swing.JLabel username;
    // End of variables declaration//GEN-END:variables
}
